#pragma once 
#include <Arduino.h>
#include "Modbus_RTU.h"

class DOSensor
{
public:
    enum FuncCode{ReadFuncCode = 0x03, //读取功能码
                    SetFuncCOde = 0x06, //写入功能码
                    ReadDO_REG = 0x0014, // DO 浓度值地址
                    ReadPH_REG = 0x0026,    // PH值地址
                    ReadTemperature_REG = 0x0010, // 温度地址
                    DevID_REG = 0x000A,  //设备ID
                    };
    enum _BaudRate {
        BaudRate_1200 = 0x0007,  //波特率-写入用
        BaudRate_2400 = 0x0000,
        BaudRate_4800 = 0x0001,
        BaudRate_9600 = 0x0002,
        BaudRate_19200 = 0x0003,
        BaudRate_38400 = 0x0004,
        BaudRate_57600 = 0x0005,
        BaudRate_115200 = 0x0006
    };
    bool ReadDO_PH_Temp_Data(void);
    float GetPH(void);
    float GetTemperature(void);
    float GetDOPercent(void);
    float GetDOValue(void);
    bool initDOSensor(Modbus_RTU * _modbus);
    bool checkDevID(void);
private:
    short tempValue;
    unsigned short DOPercent;
    unsigned short DOValue;
    unsigned short PHValue;
    unsigned int StatusREG;
    unsigned char DevID;
    Modbus_RTU * modbus;
    bool SetFunc(DOSensor::FuncCode func, short SetData);
};
